package com.cycleit.applicationexample.controller{
	import com.cycleit.applicationexample.model.ExampleResponseModel;
	import com.cycleit.cycleframework.controller.ViewController;
	import com.cycleit.cycleframework.event.ViewStateChangeEvent;
	
	import mx.collections.ArrayCollection;
	import mx.events.PropertyChangeEvent;
	
	
	public class ExampleViewController extends ViewController{
		
		public function ExampleViewController(){
			super();
			var responseModel:ExampleResponseModel = ExampleResponseModel.getInstance();
			addHandler(responseModel,"loginData",loginHandler); 
			addWatcher(responseModel,"getUsersData",new ArrayCollection(['vm','userManager',"retrieve"]));
			addWatcher(responseModel,"getUserByIdData",new ArrayCollection(['vm','userManager',"update"]));
		}
		
		 private function loginHandler(event:PropertyChangeEvent):void{
			if(ExampleResponseModel.getInstance().loginData){
				new ViewStateChangeEvent(ViewStateChangeEvent.MODIFY_VIEW,new ArrayCollection(['vm','userManager',"create","studies"])).dispatch();
			}
		} 
	}
}